function ra = respamp(activity, idxbasestart, idxbasestop, idxstimstart, idxstimstop)
baseline = mean(activity(idxbasestart:idxbasestop));
baselinesd = std(activity(idxbasestart:idxbasestop));
ra = 0;
for idx = idxstimstart:idxstimstop
    if activity(idx) > (baselinesd + baseline)
        ra = ra + (activity(idx)-baseline);
    end
end
if ra == 0
    ra = NaN;
end

